<template>
	<view class="">
		<u-navbar :is-back="true" :border-bottom="false" title="团队信息" height="46" title-color="#333" :title-bold="true"
		 :title-size="36">
			<view class="navbar-right" slot="right" @click="Store">
				确认
			</view>
		</u-navbar>
		<view class="textarea_box">
			<u-form :model="form" :rules="rules" ref="uForm" :errorType="errorType">
				<u-form-item label-width="150" :label-position="labelPosition" label="团队名称" prop="tdlb" class="name-box" :label-style="labelStyle">
					<u-input placeholder="请输入团队名称" v-model="form.tdlb.name" type="text" :custom-style="{fontSize: '30rpx',}" :height="30" @click="show=true" :clearable="false" ></u-input>
					<u-picker v-model="show" mode="selector" :range="typegz" range-key="name" 	@confirm="confirmgz"></u-picker>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="团队人数" prop="tdrs" class="name-box" :label-style="labelStyle">
					<u-input placeholder="请输入团队人数" v-model="form.tdrs" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"></u-input>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="团队能力" prop="tdnl" class="name-box"
				 :label-style="labelStyle">
					<u-input v-model="form.tdnl" type="textarea" placeholder="团队能力的简要描述" height="300" :custom-style="{fontSize: '30rpx'}"
					 :clearable="false" />
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="团队介绍" prop="tdjs" class="name-box"
				 :label-style="labelStyle">
					<u-input v-model="form.tdjs" type="textarea" placeholder="团队介绍的简要描述" height="300" :custom-style="{fontSize: '30rpx'}"
					 :clearable="false" />
				</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="团队框架" prop="name" class="name-box"
			 :label-style="labelStyle">
				<u-upload width="125" height="160" max-count="1" :action="action" ref="uUpload" :show-progress="false"
				 :preview-full-image="false" :show-upload-list="showUploadList" v-if="showUploadList" :custom-btn="true">
					<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150" style="width: 125rpx; height: 160rpx; overflow: hidden;">
						<image :src="fileList.url" mode="scaleToFill" style="height: 100%;width: 100%;"></image>
					</view>
				</u-upload>
				<u-upload width="125" height="160" max-count="1" :action="action" ref="uUpload" v-if="!showUploadList"
				 :show-progress="false" :preview-full-image="false" :show-upload-list="!showUploadList">
				</u-upload>
			</u-form-item>
			</u-form>
			<u-toast ref="uToast"/>
		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				id: "",
				show:false,
				showUploadList: false,
				form: {
					tdlb:"",
					tdrs:"",
					tdnl:"",
					tdjs:"",
					tdkj:"",
				},
				action: 'http://www.artisanchn.com/ajax/app.ashx',
				fileList: [{
					url: "",
				}],
				typegz: [],
				rules: {

				},
				errorType: ['message'],
				labelPosition: "top",
				labelStyle: {
					height: "36rpx",
					fontSize: "24rpx",
					color: "#666666",
				},
			}
		},
		async onLoad(options) {
			this.id = options.id
			if (options.index) {
				this.index = options.index
			}
			await this.lCodedata()
			await this.resumemy(options.id)
		},
		methods: {
			async resumemy(id) {
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myquery',
					para: {
						"id": id,
					}
				}
				const res = await this.$u.api.resumedata(params)
				this.form.tdlb = this.typegz.filter(item => item.id == res.Data.tdlb)[0];
				this.form.tdrs = res.Data.tdrs
				this.form.tdnl = res.Data.tdnl
				this.form.tdjs = res.Data.tdjs
				this.form.tdkj = res.Data.tdkj
				if (this.form.tdkj) {
					this.showUploadList = true
					if (this.form.tdkj.indexOf('http') == -1) {
						this.fileList.url = this.baseUrl + this.form.tdkj
					} else {
						this.fileList.url = this.form.tdkj
					}
				}
			},
			async lCodedata() {
				let params = {
					cmd: 'lCode_list_proc',
					para: {
						"pageindex": 1,
						"pagesize": 1000
					}
				}
				const res = await this.$u.api.lCodedata(params)
				this.typegz = res.Data.Data.filter(item => item.ctype == 0);
			},
			confirmgz(e){
				this.form.tdlb =  this.typegz[e[0]]
			},
			async Store() {
				let $t=this
				this.$refs.uUpload.upload();
				let files = [];
				files = this.$refs.uUpload.lists.filter(val => {
					return val.progress == 100;
				})
				let filesulr = files != "" ? files[0].url : " "
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myupdate',
					para: {
						tdlb:this.form.tdlb.id,
						tdrs:this.form.tdrs,
						tdnl:this.form.tdnl,
						tdjs:this.form.tdjs,
						tdkj:filesulr,
						"id": this.id
					}
				}
				const res = await this.$u.api.resumexgdata(params)
				if(res.ResponseID==0){
					this.$refs.uToast.show({
						title: res.Message,
						icon:false,
						duration:800,
						callback(){
						uni.$emit('refreshData');
						uni.navigateBack({
							delta: 1
						})
						}
					})
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.name-box {
		padding: 30rpx;
	}

	.navbar-right {
		margin-right: 30rpx;
		font-size: 30rpx;
	}
</style>
